<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>函数—设默认值</title>
</head>
<body>
<script>
  //给参数默认值
  function test(x, y='world') {
    console.log('默认值==>',x, y);
  }
  test();//undefined world

  let x = 'test';
  function test2(x,y=x) {
    console.log('作用域==>',x,y)
  }
  test2('ABC');//ABC ABC
  console.log('函数外x=',x)//test
</script>
</body>
</html>